package com.framework.loippi.dto.api.result;

import com.framework.loippi.entity.Ad;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@ApiModel(value = "广告列表", description = "广告列表")
public class AdListResult {
    /** ID */
    @ApiModelProperty(value = "ID")
    private Long id;
    /** 创建时间 */
    @ApiModelProperty(value = "创建时间")
    private Date createDate;
    /** 连接 */
    @ApiModelProperty("链接地址")
    private String url;
    /** 标题 */
    @ApiModelProperty(value = "标题")
    private String title;
    /** 图片 */
    @ApiModelProperty(value = "图片")
    private String image;
    /** 广告类型（1-外部链接2-图文详情3-商品详情 4-专题） */
    @ApiModelProperty(value = "广告类型（0-未配置 1-外部链接 2-图文详情 3-商品详情 4-专题 5-分类）")
    private Integer type;
    /** 商品ID */
    @ApiModelProperty(value = "商品id")
    private Long goodsId;

    /** 广告位置(1个人中心-2-报价banner图)*/
    @ApiModelProperty(value = "广告位置1-首页banner 2爱仓优选,3优品上线4口碑热销 5猜你喜欢")
    private String position;

    /** 栏目id*/
    @ApiModelProperty(value = "栏目id")
    private Long columnId;

    @ApiModelProperty(value = "分类id")
    private Long categoryId;

    @ApiModelProperty(value = "分类名称")
    private String categoryName;

    @ApiModelProperty(value = "分类级别")
    private Integer categoryLevels;

    @ApiModelProperty(value = "上级分类ID")
    private Long categoryParentId;

    public static List<AdListResult> build(List<Ad> list) {
        List<AdListResult> results = new ArrayList<>();
        AdListResult result = null;
        for (Ad ad : list) {
            result = new AdListResult();
            result.setId(ad.getId());
            result.setCreateDate(ad.getCreateDate());
            result.setGoodsId(ad.getGoodsId());
            result.setImage(ad.getImage());
            result.setTitle(ad.getTitle());
            result.setType(ad.getType());
            result.setUrl(ad.getUrl());
            result.setPosition(ad.getPosition());
            result.setColumnId(ad.getColumnId());
            result.setCategoryId(ad.getCategoryId());
            result.setCategoryName(ad.getCategoryName());
            result.setCategoryLevels(ad.getCategoryLevels());
            result.setCategoryParentId(ad.getCategoryParentId());
            results.add(result);
        }
        return results;
    }
}
